package com.wwc.controller;

import com.wwc.entities.CommonResult;
import com.wwc.entities.Payment;
import com.wwc.service.PaymentOpenFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/consumer/payment")
@Slf4j
@Api(value = "OrderController")
@RestController
public class OrderController{
	@Resource
	private PaymentOpenFeignService paymentOpenFeignService;
	
	@PostMapping(value = "/createPayment")
	@ApiOperation(value = "新增Payment数据")
	public CommonResult<Integer> createPayment(@RequestBody Payment payment){
		return paymentOpenFeignService.createPayment(payment);
	}
	
	@GetMapping("/getPaymentById/{id}")
	@ApiOperation(value = "根据id获取Payment数据")
	public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
		return paymentOpenFeignService.getPaymentById(id);
	}
	
	@GetMapping("/getDiscovery")
	@ApiOperation(value = "获取服务信息")
	public CommonResult<DiscoveryClient> getDiscovery(){
		return paymentOpenFeignService.getDiscovery();
	}
	
	@GetMapping(value = "/getService")
	@ApiOperation(value = "获取服务名称")
	CommonResult<List<String>> getService(){
		return paymentOpenFeignService.getService();
	}
	
	@GetMapping(value = "/feignTimeOut")
	@ApiOperation(value = "openfeign超时测试")
	public CommonResult<String> feignTimeOut(){
		return paymentOpenFeignService.paymentFeignTimeOut();
	}
	
}
